package com.ruoyi.project.system.filter.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.filter.domain.PaeaParaFilterCode;
import com.ruoyi.project.system.filter.service.IPaeaParaFilterCodeService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 流水过滤交易码Controller
 *
 * @author ruoyi
 * @date 2020-03-12
 */
@Controller
@RequestMapping("/system/filter")
public class PaeaParaFilterCodeController extends BaseController
{
    private String prefix = "system/filter";

    @Autowired
    private IPaeaParaFilterCodeService paeaParaFilterCodeService;

    @RequiresPermissions("system:filter:view")
    @GetMapping()
    public String filter()
    {
        return prefix + "/filter";
    }

    /**
     * 查询流水过滤交易码列表
     */
    @RequiresPermissions("system:filter:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PaeaParaFilterCode paeaParaFilterCode)
    {
        startPage();
        List<PaeaParaFilterCode> list = paeaParaFilterCodeService.selectPaeaParaFilterCodeList(paeaParaFilterCode);
        return getDataTable(list);
    }

    /**
     * 导出流水过滤交易码列表
     */
    @RequiresPermissions("system:filter:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PaeaParaFilterCode paeaParaFilterCode)
    {
        List<PaeaParaFilterCode> list = paeaParaFilterCodeService.selectPaeaParaFilterCodeList(paeaParaFilterCode);
        ExcelUtil<PaeaParaFilterCode> util = new ExcelUtil<PaeaParaFilterCode>(PaeaParaFilterCode.class);
        return util.exportExcel(list, "filter");
    }

    /**
     * 新增流水过滤交易码
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存流水过滤交易码
     */
    @RequiresPermissions("system:filter:add")
    @Log(title = "流水过滤交易码", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PaeaParaFilterCode paeaParaFilterCode)
    {
        return toAjax(paeaParaFilterCodeService.insertPaeaParaFilterCode(paeaParaFilterCode));
    }

    /**
     * 修改流水过滤交易码
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        PaeaParaFilterCode paeaParaFilterCode = paeaParaFilterCodeService.selectPaeaParaFilterCodeById(id);
        mmap.put("paeaParaFilterCode", paeaParaFilterCode);
        return prefix + "/edit";
    }

    /**
     * 修改保存流水过滤交易码
     */
    @RequiresPermissions("system:filter:edit")
    @Log(title = "流水过滤交易码", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PaeaParaFilterCode paeaParaFilterCode)
    {
        return toAjax(paeaParaFilterCodeService.updatePaeaParaFilterCode(paeaParaFilterCode));
    }

    /**
     * 删除流水过滤交易码
     */
    @RequiresPermissions("system:filter:remove")
    @Log(title = "流水过滤交易码", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(paeaParaFilterCodeService.deletePaeaParaFilterCodeByIds(ids));
    }
}
